package com.qiku.course.controller;

import com.qiku.course.entity.Course;
import com.qiku.course.entity.CourseDTO;
import com.qiku.course.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/course")
@CrossOrigin
public class CourseController {
    @Autowired
    private CourseService courseService;

    @GetMapping("/getAllCourse")
    public List<CourseDTO> getAllCourse(){
        return courseService.getAllCourse();
    }


    @GetMapping("/getCourseById/{courseId}")
    public CourseDTO getCourseById(@PathVariable("courseId") Integer courseId){
        return courseService.getCourseById(courseId);
    }
    @GetMapping("/getCoursesByUserId")
    public List<CourseDTO> getCoursesByUserId(@RequestParam("userid") Integer userId){
        System.out.println(courseService.getCoursesByUserId(userId));
        return courseService.getCoursesByUserId(userId);
    }
}
